package service.impl;

import model.VirtualMemory;
import service.PageService;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by PanD
 */

public class PageServiceImpl implements PageService {

    @Override
    public List<VirtualMemory> generateAddress() {
        Random random = new Random();
        List<VirtualMemory> addressList = new ArrayList<>();
        for (int i = 0; i < 400/4; i++) {
            int front = random.nextInt(200);
            addressList.add(new VirtualMemory(i, front, front/10, front%10));
            front++;
            addressList.add(new VirtualMemory(i+1, front, front/10, front%10));

            int behind = random.nextInt(200)+199;
            addressList.add(new VirtualMemory(i+2, behind, behind/10, behind%10));
            behind++;
            addressList.add(new VirtualMemory(i+3, behind, behind/10, behind%10 ));
        }
        return addressList;
    }
}
